/*
 * @Description: 挂接按钮
 * @Author: Zzt
 * @Date: 2023-01-04 17:53:13
 * @LastEditTime: 2023-01-06 19:20:20
 */
import { useEffect, useMemo, useState } from 'react';
import { Button } from 'antd';
import type { FC } from 'react';
import Separate from '@/components/LevelTable/componentes/dialogs/Separate';
import LinkDialog from '../dialogs/HitchItem';
import { useLibraryCollectionContext } from '../../contexts/LibraryCollectionContext';

const SAVE_TYPE = {
  CANCEL: 1,
  SAVE: 2
};

interface IHitchBtnProps {
  levelParams: any;
  upperInfo: any;
}

const HitchBtn: FC<IHitchBtnProps> = (props) => {
  const { levelParams, upperInfo } = props;
  // const { baseInfo, eRecordsData } = useLibraryCollectionContext();
  // 弹窗展示状态
  const [visible, setVisible] = useState(false);

  useEffect(() => {
    if (visible) {
      //
      // console.log('eRecordsData', eRecordsData);
    }
  }, [visible]);

  return (
    <>
      <Button
        onClick={() => {
          setVisible(true);
        }}
      >
        原文挂接
      </Button>
      {useMemo(
        () => (
          <LinkDialog
            visible={visible}
            query={levelParams}
            info={upperInfo}
            onClose={() => {
              setVisible(false);
            }}
          />
        ),
        [visible]
      )}
    </>
  );
};

export default HitchBtn;
